﻿$.ajaxSetup({
    type: 'POST',
    async: true,
    cache: false,
    dataType: 'json',
    error: function (a, b, c) {
        console.log('error');
    }
});
define(function (require, exports, module) {
    exports.ajaxAsync = function AjaxAsync(options) {
        return Wind.Async.Task.create(function (t) {
            options.error = function () {
                t.complete('failure', { success: false, message: 'error' });
            };

            options.success = function (data) {
                t.complete('success', data);
            };
            $.ajax(options);
        });
    };

    exports.comet = function () {
        var callee = arguments.callee;
        exports.ajax({
            url: 'listen.do',
            success: function (result) {
                result.Success && eval(result.Data);
            },
            complete: function () {
                callee();
            }
        });
    };
});